package com.dyz.topics.dynamicProgramming;

public class FindMaxForm474 {
    public int findMaxForm(String[] strs, int m, int n){
        int[][] dp = new int[m+1][n+1];
        for(String s:strs){
            int zero = 0;
            for(char c:s.toCharArray()){
                if(c=='0'){
                    zero++;
                }
            }
            int one = s.length()-zero;
            //自顶向下
            for(int i=m; i>=zero;i--){
                for(int j=n;j>=one;j--){
                    dp[i][j] = Math.max(dp[i][j], dp[i-zero][j-one]+1);
                }
            }
        }
        return dp[m][n];
    }
}
